package org.zcl.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.zcl.dao.TbUnionMapper;
import org.zcl.entity.TbUnion;
import org.zcl.service.TbUnion2Service;

/**
 * 工会表(TbUnion)表服务实现类
 *
 * @author Chenglin Zhu
 * @since 2022-01-06 16:28:47
 */
@Service("tbUnion2Service")
public class TbUnion2ServiceImpl extends ServiceImpl<TbUnionMapper, TbUnion> implements TbUnion2Service {

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    public void addTbUnionTransactionalException(TbUnion user) {
        try {
            TbUnion tbUnion = new TbUnion(1, user.getName() + "-exception");
            this.baseMapper.insert(tbUnion);
        } catch (Exception e) {
            throw new RuntimeException("异常测试");
        }
    }
}

